package com.boot.security.server.dao.record;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.boot.security.server.model.record.TswUserLogs;

@Mapper
public interface TswUserLogsDao {

    @Select("select * from tsw_user_logs t where t.id = #{id}")
    TswUserLogs getById(Long id);

    @Delete("delete from tsw_user_logs where id = #{id}")
    int delete(Long id);

    int update(TswUserLogs tswUserLogs);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into tsw_user_logs(user_id, oper_type, login_time, login_ip, login_source, login_method, login_note, login_remark) values(#{userId}, #{operType}, #{loginTime}, #{loginIp}, #{loginSource}, #{loginMethod}, #{loginNote}, #{loginRemark})")
    int save(TswUserLogs tswUserLogs);
    
    int count(@Param("params") Map<String, Object> params);

    List<TswUserLogs> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);
}
